Add documentation and make minor variable renames
authorChristoph Burgdorf <christoph.burgdorf@bvsn.org>
Sat, 12 Jul 2014 18:54:31 +0000 (20:54 +0200)
committerChristoph Burgdorf <christoph.burgdorf@bvsn.org>
Sun, 13 Jul 2014 20:57:05 +0000 (22:57 +0200)
src/cargo/ops/cargo_clean.rs
src/cargo/util/toml.rs

index 2d67885940d2eafd1536f9f9e2f6baa455e18f68..a9aab85d683d6bdf37064fe8451f6ef5cad921ff 100644 (file)
@@ -5,12 +5,17 @@ use ops::{read_manifest};
 use std::io::{File};
 use util::toml::{project_layout};
 
-pub fn clean(path: &Path) -> CargoResult<()>
+/// Cleans the project from build artifacts.
+
+pub fn clean(manifest_path: &Path) -> CargoResult<()>
 {
-    let mut file = try!(File::open(path));
+    let mut file = try!(File::open(manifest_path));
     let data = try!(file.read_to_end());
-    let layout = project_layout(&path.dir_path());
-    let (manifest, _) = try!(read_manifest(data.as_slice(), layout, &SourceId::for_path(path)));
+    let layout = project_layout(&manifest_path.dir_path());
+    let (manifest, _) = try!(read_manifest(data.as_slice(), 
+                                           layout, 
+                                           &SourceId::for_path(manifest_path)));
+
     let build_dir = manifest.get_target_dir();
 
     if build_dir.exists() {
index ffed1d2e0aae7f5d381761cfadbfcfa75a14ef88..85b525537edc9f33242b4e45a452851a26e40fa5 100644 (file)
@@ -11,6 +11,10 @@ use core::package_id::Metadata;
 use core::source::Location;
 use util::{CargoResult, Require, human};
 
+/// Representation of the projects file layout.
+///
+/// This structure is used to hold references to all project files that are relevant to cargo.
+
 #[deriving(Clone)]
 pub struct Layout {
     lib: Option<Path>,
@@ -45,22 +49,25 @@ fn try_add_files(files: &mut Vec<Path>, root: &Path, dir: &str) {
     }
 }
 
-pub fn project_layout(root: &Path) -> Layout {
+/// Returns a new `Layout` for a given root path.
+/// The `root_path` represents the directory that contains the `Cargo.toml` file.
+
+pub fn project_layout(root_path: &Path) -> Layout {
     let mut lib = None;
     let mut bins = vec!();
     let mut examples = vec!();
     let mut tests = vec!();
 
-    if root.join("src/lib.rs").exists() {
-        lib = Some(root.join("src/lib.rs"));
+    if root_path.join("src/lib.rs").exists() {
+        lib = Some(root_path.join("src/lib.rs"));
     }
 
-    try_add_file(&mut bins, root, "src/main.rs");
-    try_add_files(&mut bins, root, "src/bin");
+    try_add_file(&mut bins, root_path, "src/main.rs");
+    try_add_files(&mut bins, root_path, "src/bin");
 
-    try_add_files(&mut examples, root, "examples");
+    try_add_files(&mut examples, root_path, "examples");
 
-    try_add_files(&mut tests, root, "tests");
+    try_add_files(&mut tests, root_path, "tests");
 
     Layout {
         lib: lib,